import Vue from 'vue'

const PopUpConstructor = Vue.extend(require('./popup.vue'))

// 移除popup组件
PopUpConstructor.prototype.close = () => {
  popupInstance.$el.parentNode.removeChild(popupInstance.$el)
}

let popupInstance = new PopUpConstructor({
  el: document.createElement('div')
})

let popUp = (options = {}) => {
  popupInstance.innerHtml = options.innerHtml || `<p style="text-align: center">hello</p>`
  popupInstance.type = options.type || 'confirm'
  popupInstance.negtiveText = options.negtiveText || '取消'
  popupInstance.positiveText = options.positiveText || '确定'
  if (options.container) {
    document.querySelector(options.container).appendChild(popupInstance.$el)
  } else {
    document.body.appendChild(popupInstance.$el)
  }
  return popupInstance
}
export default popUp
